package com.threeti.mecool.core.domain.model.plan;

import com.threeti.mecool.core.domain.model.plan.pojo.Job;
import com.threeti.mecool.core.domain.model.project.Project;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "DM_PROJECT_CRITICAL_JOB", uniqueConstraints = @UniqueConstraint(columnNames = {"project", "job"}))
public class ProjectCriticalJob {
    private Long id;
    private Integer version;
    private Project project;
    private Job job;
    private Date startTime;
    private Date endTime;

    //<editor-fold desc="get/set">
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    public Long getId() {
        return id;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    @ManyToOne(optional = false)
    public Project getProject() {
        return project;
    }

    @ManyToOne(optional = false)
    public Job getJob() {
        return job;
    }

    @Temporal(TemporalType.DATE)
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
    public Date getStartTime() {
        return startTime;
    }

    @Temporal(TemporalType.DATE)
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
    public Date getEndTime() {
        return endTime;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public void setProject(Project project) {
        this.project = project;
    }

    public void setJob(Job job) {
        this.job = job;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    //</editor-fold>
}
